import os

from config.settings import BASE_DIR
from config.settings.components.common import DEBUG

if DEBUG:
    # 数据库配置
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, '..', 'db.sqlite3'),
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': os.getenv("MYSQL_DB"),
            'USER': "root",
            'PASSWORD': os.getenv("MYSQL_ROOT_PASSWORD"),
            'HOST': 'mysql',
            'PORT': '3306',
        }
    }


# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
